/**************************************************************************
 *
 *        Copyright (c) 2007-2008 by Sunplus mMedia Inc., Ltd.
 *
 *  This software is copyrighted by and is the property of Sunplus
 *  mMedia Inc., Ltd. All rights are reserved by Sunplus mMedia
 *  Inc., Ltd. This software may only be used in accordance with the
 *  corresponding license agreement. Any unauthorized use, duplication,
 *  distribution, or disclosure of this software is expressly forbidden.
 *
 *  This Copyright notice MUST not be removed or modified without prior
 *  written consent of Sunplus mMedia Inc., Ltd.
 *
 *  Sunplus mMedia Inc., Ltd. reserves the right to modify this
 *  software without notice.
 *
 *  Sunplus mMedia Inc., Ltd.
 *  19-1, Innovation First Road, Science-Based Industrial Park,
 *  Hsin-Chu, Taiwan, R.O.C.
 *
 **************************************************************************/
/**
 * @file		hal_disp.h
 * @brief		hal display header file.
 * @author		Ted Chiu, Matt Wang
 * @since		2008-03-14
 * @date		2008-10-03
 */

#ifndef __HAL_DISP_H__
#define __HAL_DISP_H__

/**************************************************************************
 *                              C O N S T A N T S
 **************************************************************************/
typedef enum {
	HAL_DISP_FIT_METHOD_SRC_STRETCH,
	HAL_DISP_FIT_METHOD_DST_OUTSIDE,
	HAL_DISP_FIT_METHOD_TOT,
} HAL_DispFitMethod_e;

typedef enum {
	HAL_DISP_PARA_CLK_ENABLE,
	HAL_DISP_PARA_CLK_CFG,
	HAL_DISP_PARA_GLOB_ENABLE,
	HAL_DISP_PARA_GLOB_BLEND_FACTOR,
	HAL_DISP_PARA_IMG_LAYER_ENABLE,
	HAL_DISP_PARA_IMG_LAYER_FLIP,
	HAL_DISP_PARA_IMG_LAYER_MONOCHROME_ENABLE,
	HAL_DISP_PARA_OSD_LAYER_ENABLE,
	HAL_DISP_PARA_BG_COLOR,
	HAL_DISP_PARA_DEVICE_TYPE,
	HAL_DISP_PARA_DEVICE_TOTAL_REGION,
	HAL_DISP_PARA_DEVICE_ACTIVE_REGION,
	HAL_DISP_PARA_OSD_WINDOW_OFFSET,
	HAL_DISP_PARA_OSD_WINDOW_SCROLL,
	HAL_DISP_PARA_OSD_WINDOW_SCALE_FACTOR,
	HAL_DISP_PARA_OSD_WINDOW_DIMENSION,
	HAL_DISP_PARA_OSD_FONT_SIZE,
	HAL_DISP_PARA_OSD_CHAR_INDEX,
	HAL_DISP_PARA_OSD_CHAR_ATTRIBUTE,
	HAL_DISP_PARA_OSD_BLINK_SPEED,
	HAL_DISP_PARA_OSD_BLEND_FACTOR,
	HAL_DISP_PARA_OSD_LOW_PASS_FILTER_ENABLE,
	HAL_DISP_PARA_SELECT_WINDOW_ENABLE,
	HAL_DISP_PARA_SELECT_WINDOW_REGION,
	HAL_DISP_PARA_SELECT_WINDOW_FRAME_WIDTH,
	HAL_DISP_PARA_SELECT_WINDOW_COLOR,
	HAL_DISP_PARA_INTERLACE_CFG,
	HAL_DISP_PARA_LCD_DITHER_ENABLE,
	HAL_DISP_PARA_UPS051_PIXEL_SHIFT_CFG,
	HAL_DISP_PARA_UPS051_LIGHTVIEW_ENABLE,
	HAL_DISP_PARA_UPS052_RGB_ONLY_ENABLE,
	HAL_DISP_PARA_UPS052_HSD_DELAY_CFG,
	HAL_DISP_PARA_UPS_CLK_PHASE,
	HAL_DISP_PARA_UPS_LAYOUT_MODE,
	HAL_DISP_PARA_UPS_COLOR_FILTER_CFG,
	HAL_DISP_PARA_CCIR_OUTPUT_SEQUENCE_CFG,
	HAL_DISP_PARA_GAMMA_ENABLE,
	HAL_DISP_PARA_TV_DAC_POWER_ENABLE,
	HAL_DISP_PARA_TV_SATURATION,
	HAL_DISP_PARA_TV_HUE,
	HAL_DISP_PARA_LCM_CMD_BUS_TYPE,
	HAL_DISP_PARA_LCM_CMD_BIT_WIDTH,
	HAL_DISP_PARA_LCM_CMD_PULSE_WIDTH,
	HAL_DISP_PARA_LCM_CMD_ACTIVE_LEVEL,
	HAL_DISP_PARA_LCM_DATA_FORMAT,
	HAL_DISP_PARA_LCM_RGB666_PACK_ENABLE,
	HAL_DISP_PARA_LCM_RGB666_FORMAT_10_ENABLE,
	HAL_DISP_PARA_LCM_PIXEL_ALIGN,
	HAL_DISP_PARA_LCM_COLOR_PACKAGE,
	HAL_DISP_PARA_LCM_SWITCH_G_ENABLE,
	HAL_DISP_PARA_LCM_CHANGE_RB_ENABLE,
	HAL_DISP_PARA_LCM_ONE_HALF_PIXEL_ENABLE,
	HAL_DISP_PARA_LCM_DITHER_ENABLE,
	HAL_DISP_PARA_MAX_ID,
} HAL_DispParaId_e;

typedef enum {
	HAL_DISP_CLK_SRC_SYSPLL96M = 0,
	HAL_DISP_CLK_SRC_XTAL27M   = 1,
} HAL_DispClkSrc_e;

typedef enum {
	HAL_DISP_GLOB_BLEND_SRC_IMAGE = (0 << 4),
	HAL_DISP_GLOB_BLEND_SRC_BLACK = (1 << 4),
} HAL_DispGlobBlendSrc_e;

typedef enum {
	HAL_DISP_DEVICE_TYPE_COMPOSITE_NTSC  = 0x00,
	HAL_DISP_DEVICE_TYPE_COMPOSITE_PAL   = 0x01,
	HAL_DISP_DEVICE_TYPE_CCIR601_NTSC_8  = 0x04,
	HAL_DISP_DEVICE_TYPE_CCIR601_PAL_8   = 0x05,
	HAL_DISP_DEVICE_TYPE_CCIR601_NTSC_16 = 0x06,
	HAL_DISP_DEVICE_TYPE_CCIR601_PAL_16  = 0x07,
	HAL_DISP_DEVICE_TYPE_UPS051          = 0x08,
	HAL_DISP_DEVICE_TYPE_UPS052          = 0x09,
	HAL_DISP_DEVICE_TYPE_LCM             = 0x0A,
	HAL_DISP_DEVICE_TYPE_VGA_TFT         = 0x0C,
	HAL_DISP_DEVICE_TYPE_USER_CCIR601_8  = 0x0E,
	HAL_DISP_DEVICE_TYPE_USER_CCIR601_16 = 0x0F,
} HAL_DispDeviceType_e;

typedef enum {
	HAL_DISP_PROGRESSIVE = 0x01,
	HAL_DISP_INTERLACE   = 0x02,
} HAL_DispInterlaceCfg_e;

typedef enum {
	HAL_DISP_PIXEL_SHIFT_DISABLE = 0x00,
	HAL_DISP_PIXEL_SHIFT_ODD     = 0x10,
	HAL_DISP_PIXEL_SHIFT_EVEN    = 0x30,
} HAL_DispUps051PixelShiftCfg_e;

typedef enum {
	HAL_DISP_UPS052_HSD_NO_DELAY = (1 << 0),
	HAL_DISP_UPS052_HSD_DELAY_3T = (0 << 0),
} HAL_DispUps052HsdDelayCfg_e;

typedef enum {
	HAL_DISP_UPS_LAYOUT_MODE_DISABLE       = 0x00,
	HAL_DISP_UPS_LAYOUT_MODE_ODD_DELAY_1T  = 0x08,
	HAL_DISP_UPS_LAYOUT_MODE_EVEN_DELAY_1T = 0x0C,
} HAL_DispUpsLayoutMode_e;

typedef enum {
 	HAL_DISP_UPS051_ODD_RGB = (0 << 0),
	HAL_DISP_UPS051_ODD_GBR = (1 << 0),
	HAL_DISP_UPS051_ODD_BRG = (2 << 0),
	HAL_DISP_UPS051_ODD_BGR = (3 << 0),
	HAL_DISP_UPS051_ODD_RBG = (4 << 0),
	HAL_DISP_UPS051_ODD_GRB = (5 << 0),

 	HAL_DISP_UPS052_ODD_RGB = (0 << 0),
	HAL_DISP_UPS052_ODD_GBR = (1 << 0),
	HAL_DISP_UPS052_ODD_BRG = (2 << 0),
	HAL_DISP_UPS052_ODD_RBG = (3 << 0),
	HAL_DISP_UPS052_ODD_BGR = (4 << 0),
	HAL_DISP_UPS052_ODD_GRB = (5 << 0),
} HAL_DispUpsOddColorFilter_e;

typedef enum {
 	HAL_DISP_UPS051_EVEN_BRG = (0 << 3),
 	HAL_DISP_UPS051_EVEN_RGB = (1 << 3),
	HAL_DISP_UPS051_EVEN_GBR = (2 << 3),
	HAL_DISP_UPS051_EVEN_GRB = (3 << 3),
	HAL_DISP_UPS051_EVEN_BGR = (4 << 3),
	HAL_DISP_UPS051_EVEN_RBG = (5 << 3),

 	HAL_DISP_UPS052_EVEN_RGB = (0 << 3),
	HAL_DISP_UPS052_EVEN_GBR = (1 << 3),
	HAL_DISP_UPS052_EVEN_BRG = (2 << 3),
	HAL_DISP_UPS052_EVEN_RBG = (3 << 3),
	HAL_DISP_UPS052_EVEN_BGR = (4 << 3),
	HAL_DISP_UPS052_EVEN_GRB = (5 << 3),
} HAL_DispUpsEvenColorFilter_e;

typedef enum {
	HAL_DISP_CCIR_YCRYCB = (0 << 0),
	HAL_DISP_CCIR_CRYCBY = (1 << 0),
	HAL_DISP_CCIR_YCBYCR = (2 << 0),
	HAL_DISP_CCIR_CBYCRY = (3 << 0),
} HAL_DispCcirOutputSeqCfg_e;

typedef enum {
	HAL_DISP_LCM_CMD_BUS_I80 = (0 << 3),
	HAL_DISP_LCM_CMD_BUS_M68 = (1 << 3),
} HAL_DispLcmCommandBusType_e;

typedef enum {
	HAL_DISP_LCM_CMD_8_9_BIT   = (0 << 0),
	HAL_DISP_LCM_CMD_16_18_BIT = (1 << 0),
} HAL_DispLcmCommandBitWidth_e;

typedef enum {
	HAL_DISP_LCM_DATA_FMT_RGB666 = (0 << 0),
	HAL_DISP_LCM_DATA_FMT_RGB565 = (1 << 0),
	HAL_DISP_LCM_DATA_FMT_RGB444 = (2 << 0),
	HAL_DISP_LCM_DATA_FMT_RGB332 = (3 << 0),
} HAL_DispLcmDataFormat_e;

typedef enum {
	HAL_DISP_LCM_PIXEL_ALIGN_NONE = (0 << 0),
	HAL_DISP_LCM_PIXEL_ALIGN_BIG  = (1 << 0),
	HAL_DISP_LCM_PIXEL_ALIGN_MID  = (2 << 0),
	HAL_DISP_LCM_PIXEL_ALIGN_BOTH = (3 << 0),
} HAL_DispLcmPixelAlign_e;

typedef enum {
	HAL_DISP_LCM_COLOR_PACKAGE_RGB  = (1 << 0),
	HAL_DISP_LCM_COLOR_PACKAGE_BGR  = (0 << 0),
} HAL_DispLcmColorPackage_e;

typedef enum {
	HAL_DISP_WAIT_HVALID = (1 << 0),
	HAL_DISP_WAIT_HSYNC  = (1 << 1),
	HAL_DISP_WAIT_VVALID = (1 << 2),
	HAL_DISP_WAIT_VSYNC  = (1 << 3),
} HAL_DispWaitSource_e;

typedef enum {
	HAL_DISP_WAIT_FALLING = 0,
	HAL_DISP_WAIT_RISING  = 1,
	HAL_DISP_WAIT_HIGH    = 2,
	HAL_DISP_WAIT_LOW     = 3,
} HAL_DispWaitMode_e;

#define HAL_DISP_LCM_CMD_INST  0x01000000L
#define HAL_DISP_LCM_CMD_PARA  0x02000000L
#define HAL_DISP_LCM_CMD_WAIT  0x03000000L
#define HAL_DISP_LCM_CMD_STOP  0x04000000L

/**************************************************************************
 *                  F U N C T I O N   D E C L A R A T I O N S
 **************************************************************************/
void HAL_DispFitMethodSet(UINT8 method);
UINT8 HAL_DispImgZoomSet(UINT16 hsize, UINT16 vsize, UINT16 zoomfac);
UINT8 HAL_DispImgPanSet(SINT16 xoff, SINT16 yoff);
void HAL_Display_enable(void);

void HAL_DispPbFrameBufferSet(UINT32 addr, UINT16 w, UINT16 h);
void HAL_DispPbFrameBufferGet(UINT32 *paddr, UINT16 *pw, UINT16 *ph);

void HAL_DispOsdFontBufferAddrSet(UINT32 addr);
void HAL_DispOsdFontBufferAddrGet(UINT32 *paddr);
UINT8 HAL_DispOsdFontShapeSet(UINT32 addr, UINT16 begIdx, UINT16 len);

UINT8 HAL_DispParaSet(UINT8 id, SINT16 para1, SINT16 para2, SINT16 para3, SINT16 para4, UINT8 upd);
UINT8 HAL_DispOsdPaletteSet(UINT8 *paltTbl, UINT16 begIdx, UINT16 len);
UINT8 HAL_DispGammaTableSet(UINT8 *gammaTbl);

UINT8 HAL_DispSignalWait(UINT8 src, UINT8 mode);

UINT8 HAL_DispLcmCmdTableSend(UINT32 *cmdTbl);

#endif  /* __HAL_DISP_H__ */

